package com.ponchware.classes
{
	import flash.display.Shape;

	public class Particle extends Shape
	{
		private const MAX_RADIUS:Number = 5;
		private const GRAVITY:Number = .5;
		
		private var radius:Number = 0;
		private var angle:Number = 0;
		private var xspeed:Number = 0;
		private var yspeed:Number = 0;
		private var speed:Number = 0;
		
		private var origY:Number = 0;
		
		public function Particle(px:Number, py:Number, angle:Number, speed:Number)
		{
			super();
			this.x = px;
			this.y = py;
			this.origY = py;
			this.angle = angle;
			this.speed = speed;
			
			// Calculate random size of particle
			this.radius = Math.random() * MAX_RADIUS;
			
			// Calculate xspeed and yspeed
			xspeed = speed * Math.cos(angle);
			yspeed = 0 - speed * Math.sin(angle);
			
			//this.width = radius;
			//this.height = radius;
			
			draw();
		}
		
		private function draw():void
		{
			//trace("drawing");
			// TODO
			graphics.clear();
			graphics.lineStyle(2);
			graphics.beginFill(0xFFFFFF);
			graphics.drawCircle(radius/2, radius/2, this.radius);
			graphics.endFill();
		}
		
		public function updatePosition():void
		{
			// Update our position
			x += xspeed;
			y += yspeed;
				
			// Update "gravity"
			yspeed += GRAVITY;
		}
	}
}